
#include "ContactListener.h"
//#include "Constants.h"

USING_NS_CC;

ContactListener::ContactListener() {
}

ContactListener::~ContactListener() {
}

void ContactListener::BeginContact(b2Contact *contact) {
	//GameObject *o1 = (GameObject*)contact->GetFixtureA()->GetBody()->GetUserData();
	//GameObject *o2 = (GameObject*)contact->GetFixtureB()->GetBody()->GetUserData();
	CCSprite* o1 = (CCSprite *)contact->GetFixtureA()->GetBody()->GetUserData();
	CCSprite* o2 = (CCSprite *)contact->GetFixtureB()->GetBody()->GetUserData();
	CCLOG("-----> Player made contact with platform!");

	 MyContact myContact = { contact->GetFixtureA(), contact->GetFixtureB() };
	    _contacts.push_back(myContact);


}

void ContactListener::EndContact(b2Contact *contact) {
	//GameObject *o1 = (GameObject*)contact->GetFixtureA()->GetBody()->GetUserData();
	//GameObject *o2 = (GameObject*)contact->GetFixtureB()->GetBody()->GetUserData();


	CCLOG("-----> Player lost contact with platform!");
	  MyContact myContact = { contact->GetFixtureA(), contact->GetFixtureB() };
	    std::vector<MyContact>::iterator pos;
	    pos = std::find(_contacts.begin(), _contacts.end(), myContact);
	    if (pos != _contacts.end())
	    {
	        _contacts.erase(pos);
	    }
}

void ContactListener::PreSolve(b2Contact *contact, const b2Manifold *oldManifold) {
}

void ContactListener::PostSolve(b2Contact *contact, const b2ContactImpulse *impulse) {
}
